import 'package:flutter/material.dart';

//状态组件
class zhuangtaizujian extends StatefulWidget {
  const zhuangtaizujian({super.key});

  @override
  State<zhuangtaizujian> createState() => _zhuangtaizujianState();
}

class _zhuangtaizujianState extends State<zhuangtaizujian> {
  String name = '张三';
  int age = 20;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      //导航条
      appBar: AppBar(
        title: Text('状态组件',
            style: TextStyle(
                fontSize: 24,
                fontWeight: FontWeight.w600,
                color: Colors.white)),
        centerTitle: true,
        backgroundColor: Colors.pink,
      ),
      //主体区域
      body: Center(
        child: Text(
          '我叫$name,今年$age岁',
          style: TextStyle(fontSize: 25),
        ),
      ),

      //修改状态
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            age += 1;
          });
        },
        child: Icon(Icons.add),
      ),
    );
  }
}
